<template>
  <NavBack title="添加收货地址"></NavBack>
  <van-address-edit
    :area-list="areaList"
    show-delete
    show-set-default
    show-search-result
    :search-result="searchResult"
    :area-columns-placeholder="['请选择', '请选择', '请选择']"
    @save="onSave"
    @delete="onDelete"
    @change-detail="onChangeDetail"
  />

  <!-- <p>{{$router.quer.addressid}}</p> -->
</template>

<script>
import { areaList } from "@vant/area-data";
import NavBack from "../../components/NavBack.vue";
import { showSuccessToast } from 'vant';
export default {
  components: {
    NavBack,
  },
  data() {
    return {
      areaList,
    };
  },
  created(){

  },
  methods: {
    onSave(info) {
      this.address(info);
    },
    address(info) {
      this.$http({
        url: "/address/add",
        method: "post",
        data: {
          userid: localStorage.getItem("userid"),
          name: info.name,
          tel: info.tel,
          province: info.province,
          city: info.city,
          county: info.county,
          addressDetail: info.addressDetail,
          isDefault: info.isDefault,
        },
      }).then((res) => {
        if (res.data.code === "200") {
          showSuccessToast('添加成功');
          // console.log(res);
          this.$router.push("/myaddress");
        }
      });
    },
  },
};
</script>

<style>
</style>